Bit of refactoring here and there...
Removed test bugs