Massive bug fixing