added various new features and fixed up the second round