Simplify. Use an array, no need for complicated id generation.
Make sure main file is built first.
Update build