Tried to implement #8 (Have to be tested) + Some fixes