Each function returns value instead of 'echo'
Added internal-functions. I really don't understand the point of serialize()
Added unset($nothing) before first conditional