Updated with latest changes from egzpo