Removed some debug statements, refactoring