Fix and improve formatting of doc strings and comments