Yet more refactoring
Fix edit bug