Fixes

Fixes #339, #333, #363, #361, #385, #382.