Cancel Button for popup + some code cleanup