lightning and some cleanup work