Incorporating changes by kguelzau

Comment thread: #2329
Pull request: #2476