Cleaned up code a bit. Changed entry check conditions to regular expressions.