Various fixes (for #25, #39 and #26)