performance improvements, cleanup