Bug fixes
Get rid of unused code