Proposed fix for #136

This fixes #136.

Please check if I haven broken anything in the process. ;)