Integrated onye's changes to my changes from before.