many fixes, styling updates, commenting is more robust