Fixing bugs + Refactoring