Many fixes and improvements, proper implementation of variables.