Created encodeAMF + fixed some bugs