Tweaks and added more debug messages