Adding domain control to catch errors and some minor changes