Prepared statements partially + various fixes