Fixing some errors, adding more debug