This also cleans up the bar chart code slightly and fixes some minor bugs that were detected in related code. Closes #244