Changed and fixed Database class