improve formatting, simplify code and clarification, fix and add links