Code Cleanup and Simplification of Plugin