Fixed a number of performance problems + hella debugging output