Refactored/restructured code, fixed UITextFieldDelegate.