Removed obsolete code, rearranged a little existing code.