Adding documentation and improving formatting