Use constants and calculation instead of hardcoded numbers. Fixed some style nits.