Pile o bugfixes from late night commit