Some changes to code style and explanations