final code tidbits & fine tuning