lots of cleanup, added a nice prelude of sorts to keep common types/functions in