Changed some if()s and added documentation.