add functionality and a lot of stuff

Without this the code will not run and also a lot of fine stuff makes it
easier in the future to update this code.