MadAppLayer

Slight improvements, discovered some bugs. Will fix it by Friday.