Basic redesign, minor code refactoring