Improved error messages and lua documentation