Refactoring code
Fixed all unresolved issues.