Lotta bug fixes