Edited for style - fixed some JSHint problems, e.g. tabs to spaces, white space and adding 0 to .5 etc.