Code cleanup and minor modifications.