Code Refactoring, Minor Fixes