Several bugs dealt with