Cleanups and code additions. Gallery being the main one