module and function fixes. slight code tweaks