Various bugs removed