A number of fixes

#206, #225, #226, #116