Mainly bug fixing