Minor Bug Fixes & Refactoring