Restore some functions + added flags :)