Merge "Refactoring and cleanup"