Bug fixes

See commit log