Added features and started refactoring code