Code cleanup and feature update