Fixed various bug with editing