fixing memory errors
tweaks