Add more documentation and comments