refactoring successfull! Also squashed more bugs