Improving and documenting lua code