Complete rewrite of lib_lighting.rb