Several improvements, make it more robuts, add authentication