Clean up and small optimization