minor bug fixes. Still figuring out re-ordering