fixing arithmetic errors
minor
cosmetic tweaks