Styling fixes and algorithm fixes