Added focus event to forms; cleaned up code