Fix bugs #1 #4 #5