Merged some of greg's changes made some adjustments