Fixed bugs with editing, did some validation.