Refactoring of existing Functions

restore my changes from a decompiled version. That means the commit history is lost. Sorry.