Mostly cleanup

Based on some very basic testing it seems to work.