Changes with working local copy to fix creation bug and code refactoring