Cleanups and a bugfix