Fixes few bugs and refactored code