Cleanup some functions
Refactoring some methods