Merging LordFokas' changes into my fork