Fixed a bug reported by Simon Janežič <simon.janezic@gmail.com>