To be honest, this class was written by Matei :)