Ton of bug-fixing