Fix #8 #5 and #6