Adding documentation and improving structure