clean up lib and middleware dir structure