Cleanup and redesign a bit