Add comments and improve docs