fix for bugs and code