Minimal clean up and logic added