move plugin related code to seperate files