Mainly cleanups and bugfixes.

\o/