Implement move to lib and auto move to lib as well as various small bug fixes.