add various improvements and cleanups