Moved code to a proper file, backwards compatible.