Better formating and a few bug fixes