Refactored markup and javascript, added edit mode in frontend