Various clean up

Will update this branch with more commits soon.