Cleaned up by moving functions to plugins