Updated with the latest changes from luka's dropbox