Tidied up code and fixed a bug in the cancel button href