Modified some code_tools funcationality to make it more generic.