Fix for #118 and #132