Fixes #142. Fixes #139. Fixes for #141