Readability fixes for review. STILL TO DO: improve testcases.