Changed and implemented  some database stuff