Improvements to the code according to feedback