Minor bug fixes and refactors.
Rebuilt.