Improvements based on feedback from @vincenthz