Removal of non-hydrocarbon compounds