Form tweaks and remove duplicate code