Outsourced initialization code
Added edit-mode