Code cleanup and other small changes