Added logging; minor improvements