I'm willing to give you some help on optimizing your code, but you should first try Guillaume Germain's profiler to understand where the time is spent (Guillaume has profile your original code and the results are at: http://www.iro.umontreal.ca/~germaing/tmp/richter/). Quite cool stuff!
Marc