Bug fixes for running on EMR