Fix #11, #25 and #30.