SSP-1927 Code cleanup and fix for 'past term' functionality