Updated code to work with new API (v1.1) - thanks to maniqui
Merge branch 'v4'