code cleanup and trying to get after and before working, unstable!