Cleanup/refactor

Will probably do some more work; a few improvements to be made here and there