source formatting, fixed buggy code, cleaned up typos