Non-stupid JS architecture