Lots of style changes as well as some bug fixes