Code cleanup and commenting for polycals