Misc Refactorings & fixes