Separate ui and state logic in puzzle view. Fix few bugs. Close #12.