Updated code to remove a couple of mistakes and set some defaults.