Several updates. Semi-working version