Further debugging, optimization, and style