cleaned up, reorganized; still WIP