Some bug fixing. More to come