Fix #10, #11 and #12