Issue 321

Solves #321

I prefer to issue a PR with this instead of joining it with #315. Also, #315 became a merge conflict hell and it is taking me too long to fix it, so I'll probably close it and issue a new PR soon.