Dan's fixes and modifications