Bug fixes / Code cleanup