A few tweaks to the code to make it more readable