Tiny changes here and there, mostly debugging and refactoring