Bugfix for #7 and feature for #4