JC: cleaned up code.