BZ-1022140: cleaning up the code