Made the code slightly more Scala-ish and added two profiling methods
Removed profiling code