Fixed segfault in light manager

Also fixed minor memory leak