Fixed bugs
Dirty version