Fixed #9, #4 and #3