Added comments and optimizations

Signed-off-by: Levi Gross <levi@levigross.com>