cleanup and minor modifications