Added DEBUG logging, fixed some warnings