fix id generation. general cleanup