Fixed Bugs. Slight performance improvements