code refactoring, w/ prototype inheritance fixes