fixed few errors and added UDP support