Add more variables and bug fixes