scattered fixes and optimizations as I've been trying to get this running on the cluster