Minor fixes & refactoring and stuff.