Changed the layout Resolver to give safer errors

This required making the layout resolver monadic
Also made a few other error's safer throughout the compiler