Fix bugs
Remove unused code