reorganize and clean up a bit