Some code clean-up and refactoring; Implemented abstraction for Debug