Implemented constraint solving, reorganized things